package org.example.lock;

import java.util.concurrent.locks.LockSupport;

public class LockSupportExample {

    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(() -> {
            System.out.println("Thread 1 is starting...");
            LockSupport.park(); // Thread 1 will block here until it is unparked
            System.out.println("Thread 1 is woken up!");
        });

        t1.start();

        Thread.sleep(1000); // Let t1 start and block
        LockSupport.unpark(t1); // Wake up t1

        // Wait for t1 to finish
        try {
            t1.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
